<template>
	<view class="uni-padding-wrap uni-common-mt">
		<view class="uni-pagination-box">
			<uni-pagination :page-size="pageSize" :current="pageNo" :total="rowCount" @change="changePage"  />
		</view>
		<view class="uni-container">
			<FlightOrderList :dataList="dataList" :loading="loading"></FlightOrderList>
		</view>
		<view class="uni-pagination-box">
			<uni-pagination :page-size="pageSize" :current="pageNo" :total="rowCount" @change="changePage"  />
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onShow,
		onLoad
	} from '@dcloudio/uni-app'
	import {
		searchFlightOrders
	} from "@/common/api/flight.js";
	import FlightOrderList from "@/components/list/flight-order-list_h5.vue";

	let dataList = ref([])
	let loading = ref(false)

	let rowCount = ref(0)
	let pageNo = ref(1)
	let pageSize = ref(10)
	let pageTotal = ref(0)

	let beginDate = ""
	let endDate = ""
	let name = ""
	let idno = ""
	let ticketNo = ""
	let pnrNo = ""
	let status = -1
	let customerId = -1
	let customerType = -1
	let intlTicket = -1
	let workStatus = 0
	let onlyMine = 0
	let op1 = ""
	let orderNo = ""
	let payStatus = -1
	let flightNo = ""
	let ddate = ""

	let stat = null
	
	onLoad(() => {
		search();
	})

	function search() {
		loading.value = true
		uni.showLoading({
			title: "查询中......"
		})
		dataList.value.splice(0)
		const params = {
			"sc.pageNo": pageNo.value,
			"sc.pageSize": pageSize.value,
			"sc.beginDate": beginDate,
			"sc.endDate": endDate,
			"sc.name": name,
			"sc.idno": idno,
			"sc.status": status,
			"sc.customerId": customerId,
			"sc.customerType": customerType,
			"sc.ticketNo": ticketNo,
			"sc.intlTicket": intlTicket,
			"sc.pnrNo": pnrNo,
			"sc.workStatus": workStatus,
			"sc.onlyMine": onlyMine,
			"sc.op1": op1,
			"sc.orderNo": orderNo,
			"sc.payStatus": payStatus,
			"sc.departureDate": ddate,
			"sc.flightNo": flightNo,
		};
		searchFlightOrders(
			params,
			(jsonResult) => {
				dataList.value = jsonResult.dataList
				pageNo.value = jsonResult.page.pageNo
				pageTotal.value = jsonResult.page.pageTotal
				rowCount.value = jsonResult.page.rowCount
			},
			() => {
				loading.value = false
				uni.hideLoading()
			}
		);
	}

	function reset() {
		this.beginDate = "";
		this.endDate = "";
		this.name = "";
		this.idno = "";
		this.ticketNo = "";
		this.pnrNo = "";
		this.status = -1;
		this.sc.pageNo = 1;
		this.onlyMine = 0;
		this.op1 = "";
		this.orderNo = "";

		this.ddate = "";
		this.flightNo = "";

		this.customerId = -1;
		// this.search()
	}
	
	function changePage(e) {
		pageNo.value = e.current
		search()
	}

</script>